
/*留言反馈*/
Ext.define('qjtravel.view.Comment', {
    extend: 'Ext.Container',
    xtype: 'comment',

    requires:[
        'Ext.data.Store',
        'Ext.field.Search'
    ],

    config:{
        layout:'card',
        items:[
            {
                xtype:'titlebar',
                docked:'top',
                title:'留言反馈',
                items:[
                    {
                        xtype:'button',
                        text:'返回',
                        handler:function(){
                            Ext.Viewport.remove(this.up('comment'),true);
                        }
                    },
                    {
                        xtype:'button',
                        text:'我要留言',
                        align:'right',
                        handler:function(){
                            Ext.Viewport.animateActiveItem('commentAdd', {type: 'slide', direction: 'left'});
                           // this.up('comment').hide();
                           // Ext.Viewport.add([{xtype:'commentAdd'}]).show({type: 'slide', direction: 'left'});
                        }
                    }
                ]
            },
            {
                xtype:'list',
                scrollable: true,
                selectedCls:false,
                emptyText:'沙发空缺中，点击右上角按钮进行留言',
                store:'Comment',
                itemTpl:new Ext.XTemplate(
                    "<tpl if='remessage'>",
                        "<div>"+
                            "<div class='font1 color2' style='width: 80%;overflow: hidden;height: 30px; line-height: 30px;'>{messages}</div>" +
                            "<div style=' position: absolute;top:10px; right:40px; line-height: 30px;'><img src='resources/images/message.png' height='20px' style='float: right' /></div>"+
                            "<div class='news_date font3 color1' style='line-height: 10px'>{[Ext.Date.format(new Date(parseInt(values.lasttime) * 1000), 'Y-m-d')]}</div>"+
                        "</div>",
                    "<tpl else>",
                        "<div>"+
                            "<div class='font1 color2' style='width: 80%;overflow: hidden;height: 30px; line-height: 30px;'>{messages}</div>"+
                            "<div class='news_date font3 color1' style='line-height: 10px'>{[Ext.Date.format(new Date(parseInt(values.lasttime) * 1000), 'Y-m-d')]}</div>"+
                        "</div>",
                    "</tpl>"
                ),


                listeners: {
                    initialize: function () {
                        var News = Ext.getStore('Comment');
                        News.load({params: {cadid:'6'} });
                    },
                    itemtap: function(list, index, element, record){
                        Ext.Viewport.animateActiveItem('commentDetail', {type: 'slide', direction: 'left'});
                        Ext.getCmp('messages').setHtml(record.getData().messages);
                        if(record.getData().remessage==''){
                            Ext.getCmp('remessage').setHtml('暂无回复');
                        }else{
                            Ext.getCmp('remessage').setHtml(record.getData().remessage);
                        }

                    }
                }
            }
        ],listeners: {
            back:function() {
                Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);
            }
        }
    }
});





